package nix.struts.ognl;

import nix.struts.ognl.domain.User;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.Preparable;
import com.opensymphony.xwork2.util.ValueStack;

/**
 * 模型驱动原理：实现准备拦截器接口，prepare会在params拦截器之前执行。——这个过程封装为ModelDriven拦截器
 */
public class Demo2Action extends ActionSupport implements Preparable {

	private User user = new User();
	
	@Override
	public String execute() throws Exception {
		
		System.out.println(user);
		return SUCCESS;
	}

	@Override
	public void prepare() throws Exception {
		// 获得值栈
		ValueStack vs = ActionContext.getContext().getValueStack();
		// 压栈
		vs.push(this.user);
	}
}
